{
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "# Polynomial Regression"
      ],
      "metadata": {}
    },
    {
      "cell_type": "markdown",
      "source": [
        "Polynomial Regression is a technique that is used for a nonlinear equation byt taking polynomial functions of indepedent variable.      \n",
        "\n",
        "Transform the data to polynomail. Polynomial regression is for special case of the general linear regression model. It is useful for describing curvilinear relationships. Curvilinear relationships have by squaring or setting higher-order terms of the predictor variables.\n",
        "\n",
        "Quadratic - 2nd order       \n",
        "Cubic - 3rd order       \n",
        "Higher order"
      ],
      "metadata": {}
    },
    {
      "cell_type": "code",
      "source": [
        "import numpy as np\n",
        "import matplotlib.pyplot as plt\n",
        "import pandas as pd\n",
        "\n",
        "import warnings\n",
        "warnings.filterwarnings(\"ignore\")\n",
        "\n",
        "# fix_yahoo_finance is used to fetch data \n",
        "import fix_yahoo_finance as yf\n",
        "yf.pdr_override()"
      ],
      "outputs": [],
      "execution_count": 1,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# input\n",
        "symbol = 'AMD'\n",
        "start = '2014-01-01'\n",
        "end = '2018-08-27'\n",
        "\n",
        "# Read data \n",
        "dataset = yf.download(symbol,start,end)\n",
        "\n",
        "# View Columns\n",
        "dataset.head()"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "[*********************100%***********************]  1 of 1 downloaded\n"
          ]
        },
        {
          "output_type": "execute_result",
          "execution_count": 2,
          "data": {
            "text/html": [
              "<div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>Open</th>\n",
              "      <th>High</th>\n",
              "      <th>Low</th>\n",
              "      <th>Close</th>\n",
              "      <th>Adj Close</th>\n",
              "      <th>Volume</th>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>Date</th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "      <th></th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>2014-01-02</th>\n",
              "      <td>3.85</td>\n",
              "      <td>3.98</td>\n",
              "      <td>3.84</td>\n",
              "      <td>3.95</td>\n",
              "      <td>3.95</td>\n",
              "      <td>20548400</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2014-01-03</th>\n",
              "      <td>3.98</td>\n",
              "      <td>4.00</td>\n",
              "      <td>3.88</td>\n",
              "      <td>4.00</td>\n",
              "      <td>4.00</td>\n",
              "      <td>22887200</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2014-01-06</th>\n",
              "      <td>4.01</td>\n",
              "      <td>4.18</td>\n",
              "      <td>3.99</td>\n",
              "      <td>4.13</td>\n",
              "      <td>4.13</td>\n",
              "      <td>42398300</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2014-01-07</th>\n",
              "      <td>4.19</td>\n",
              "      <td>4.25</td>\n",
              "      <td>4.11</td>\n",
              "      <td>4.18</td>\n",
              "      <td>4.18</td>\n",
              "      <td>42932100</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2014-01-08</th>\n",
              "      <td>4.23</td>\n",
              "      <td>4.26</td>\n",
              "      <td>4.14</td>\n",
              "      <td>4.18</td>\n",
              "      <td>4.18</td>\n",
              "      <td>30678700</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>"
            ],
            "text/plain": [
              "            Open  High   Low  Close  Adj Close    Volume\n",
              "Date                                                    \n",
              "2014-01-02  3.85  3.98  3.84   3.95       3.95  20548400\n",
              "2014-01-03  3.98  4.00  3.88   4.00       4.00  22887200\n",
              "2014-01-06  4.01  4.18  3.99   4.13       4.13  42398300\n",
              "2014-01-07  4.19  4.25  4.11   4.18       4.18  42932100\n",
              "2014-01-08  4.23  4.26  4.14   4.18       4.18  30678700"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 2,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "dataset.shape"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 3,
          "data": {
            "text/plain": [
              "(1172, 6)"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 3,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "X = dataset.iloc[ : , 0:4].values\n",
        "Y = dataset.iloc[ : ,  4].values"
      ],
      "outputs": [],
      "execution_count": 4,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.preprocessing import PolynomialFeatures\n",
        "from sklearn.linear_model import LinearRegression"
      ],
      "outputs": [],
      "execution_count": 5,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Splitting the dataset into the Training set and Test set\n",
        "from sklearn.model_selection import train_test_split\n",
        "X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size = 0.2, random_state = 0)"
      ],
      "outputs": [],
      "execution_count": 6,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# PolynomialFeatures (prepreprocessing)\n",
        "poly = PolynomialFeatures(degree=3)\n",
        "X_ = poly.fit_transform(X)\n",
        "X_test_ = poly.fit_transform(X_test)"
      ],
      "outputs": [],
      "execution_count": 7,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Linear Model\n",
        "lg = LinearRegression()\n",
        "\n",
        "# Fit\n",
        "lg.fit(X_, Y)\n",
        "\n",
        "# Obtain coefficients\n",
        "lg.coef_"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 8,
          "data": {
            "text/plain": [
              "array([  1.62688481e-11,   1.85764964e-12,  -7.80250018e-13,\n",
              "        -2.69424404e-12,   1.00000000e+00,   4.47052037e-13,\n",
              "        -3.82903837e-13,  -1.39216066e-12,   8.17674568e-13,\n",
              "        -1.14370455e-14,   9.75399638e-13,  -4.82328634e-13,\n",
              "         1.05600607e-12,  -1.60400107e-12,   5.87707676e-13,\n",
              "        -2.83039766e-15,   5.99757042e-15,   4.41002252e-15,\n",
              "         9.47274379e-15,  -1.28813313e-14,  -6.05981083e-15,\n",
              "        -8.43161846e-15,  -6.80891094e-15,   3.66193025e-15,\n",
              "        -2.39515640e-16,   1.63940678e-14,   5.36875253e-15,\n",
              "        -8.20614218e-15,   9.90135221e-15,  -9.00849027e-15,\n",
              "        -1.60832457e-14,  -2.98519388e-15,  -1.14820952e-15,\n",
              "         5.63225424e-15,   1.35999520e-14])"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 8,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "lg.intercept_"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 9,
          "data": {
            "text/plain": [
              "-1.5975665235146153e-11"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 9,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "lg.score(X_, Y)"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 10,
          "data": {
            "text/plain": [
              "1.0"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 10,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Predict\n",
        "lg.predict(X_test_[[0]])"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 11,
          "data": {
            "text/plain": [
              "array([ 12.83])"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 11,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "X = dataset.iloc[:,0:1].values\n",
        "Y = dataset.iloc[:,4].values"
      ],
      "outputs": [],
      "execution_count": 12,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "poly=PolynomialFeatures(degree=3)\n",
        "poly_x=poly.fit_transform(X)\n",
        "\n",
        "regressor=LinearRegression()\n",
        "regressor.fit(poly_x,Y)"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 13,
          "data": {
            "text/plain": [
              "LinearRegression(copy_X=True, fit_intercept=True, n_jobs=None,\n",
              "         normalize=False)"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 13,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "plt.scatter(X,Y,color='red')\n",
        "plt.plot(X,regressor.predict(poly.fit_transform(X)),color='blue')\n",
        "plt.show()"
      ],
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "image/png": [
              "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3Xl8VdW99/HPLwGEAFUIaJ1IKup9FGXQaJ3qBFqlA7Veq21AHBA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bgPOecrx8YJvgcTsX7T2wHrAfGhcaT/cbMTgJeBVYBTcHD/4U3flww34Ukn8OPSeN3QYEuIuITGnIREfEJBbqIiE8o0EVEfEKBLiLiEwp0ERGfUKCLiPiEAl1ExCcU6CIiPvH/ASZ/HPQTGrHoAAAAAElFTkSuQmCC\n"
            ],
            "text/plain": [
              "<Figure size 432x288 with 1 Axes>"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 14,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Calculate Polynomial of 3rd order using one independent variable"
      ],
      "metadata": {}
    },
    {
      "cell_type": "code",
      "source": [
        "X = np.array(dataset['Open'].values)\n",
        "Y = np.array(dataset['Adj Close'].values)"
      ],
      "outputs": [],
      "execution_count": 15,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from scipy import *\n",
        "\n",
        "f = np.polyfit(X,Y,3)\n",
        "p = np.poly1d(f)\n",
        "print(p)"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "           3            2\n",
            "0.0001808 x - 0.004963 x + 1.037 x - 0.06515\n"
          ]
        }
      ],
      "execution_count": 16,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Polynomial of multiple independent variables"
      ],
      "metadata": {}
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.preprocessing import PolynomialFeatures\n",
        "from sklearn import linear_model"
      ],
      "outputs": [],
      "execution_count": 17,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "X = np.array(dataset[['Open', 'High', 'Low']].values)\n",
        "Y = np.array(dataset['Adj Close'].values)"
      ],
      "outputs": [],
      "execution_count": 18,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "Y = Y.reshape(1172, -1)"
      ],
      "outputs": [],
      "execution_count": 19,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "poly = PolynomialFeatures(degree=3)\n",
        "X_ = poly.fit_transform(X)\n",
        "predict_ = poly.fit_transform(Y)"
      ],
      "outputs": [],
      "execution_count": 20,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Polynomial Regression with more than One Dimension"
      ],
      "metadata": {}
    },
    {
      "cell_type": "code",
      "source": [
        "pr = PolynomialFeatures(degree=2)"
      ],
      "outputs": [],
      "execution_count": 21,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "X = np.array(dataset[['High', 'Low']].values)\n",
        "Y = np.array(dataset['Adj Close'].values)"
      ],
      "outputs": [],
      "execution_count": 22,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "X_poly = pr.fit_transform(X)"
      ],
      "outputs": [],
      "execution_count": 23,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Pre-processing\n",
        "from sklearn.preprocessing import StandardScaler\n",
        "\n",
        "# Normalize the each feature simultaneously\n",
        "SCALE =  StandardScaler()\n",
        "SCALE.fit(X)\n",
        "\n",
        "x_scale = SCALE.transform(X)"
      ],
      "outputs": [],
      "execution_count": 24,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Example Polynomial"
      ],
      "metadata": {}
    },
    {
      "cell_type": "code",
      "source": [
        "# Pipeline\n",
        "from sklearn.pipeline import Pipeline\n",
        "\n",
        "X = np.array(dataset['Open'].values)\n",
        "Y = np.array(dataset['Adj Close'].values)\n",
        "X = X.reshape(1172, -1)\n",
        "Y = Y.reshape(1172, -1)\n",
        "\n",
        "Input=[('scale',StandardScaler()),('polynomial', PolynomialFeatures(include_bias=False)),('model',LinearRegression())]\n",
        "pipe = Pipeline(Input)\n",
        "pipe.fit(X,Y)\n",
        "yhat = pipe.predict(Y)\n",
        "yhat[0:4]"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 25,
          "data": {
            "text/plain": [
              "array([[ 3.94746384],\n",
              "       [ 3.99709476],\n",
              "       [ 4.12615426],\n",
              "       [ 4.17579988]])"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 25,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "Different Example Method"
      ],
      "metadata": {}
    },
    {
      "cell_type": "code",
      "source": [
        "from sklearn.preprocessing import PolynomialFeatures\n",
        "from sklearn import linear_model\n",
        "\n",
        "msk = np.random.rand(len(dataset)) < 0.8\n",
        "train = dataset[msk]\n",
        "test = dataset[~msk]\n",
        "\n",
        "train_x = np.asanyarray(train[['Open']])\n",
        "train_y = np.asanyarray(train[['Adj Close']])\n",
        "\n",
        "test_x = np.asanyarray(test[['Open']])\n",
        "test_y = np.asanyarray(test[['Adj Close']])\n",
        "\n",
        "poly = PolynomialFeatures(degree=2)\n",
        "train_x_poly = poly.fit_transform(train_x)\n",
        "train_x_poly"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 26,
          "data": {
            "text/plain": [
              "array([[   1.        ,    3.85      ,   14.8225    ],\n",
              "       [   1.        ,    4.01      ,   16.0801    ],\n",
              "       [   1.        ,    4.19      ,   17.5561    ],\n",
              "       ..., \n",
              "       [   1.        ,   21.190001  ,  449.01614238],\n",
              "       [   1.        ,   22.91      ,  524.8681    ],\n",
              "       [   1.        ,   24.940001  ,  622.00364988]])"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 26,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "clf = linear_model.LinearRegression()\n",
        "train_y_ = clf.fit(train_x_poly, train_y)\n",
        "# The coefficients\n",
        "print('Coefficients: ', clf.coef_)\n",
        "print('Intercept: ',clf.intercept_)"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Coefficients:  [[ 0.          0.98085282  0.00110105]]\n",
            "Intercept:  [ 0.05505099]\n"
          ]
        }
      ],
      "execution_count": 27,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "plt.scatter(train[['Open']], train[['Adj Close']],  color='blue')\n",
        "XX = np.arange(0.0, 10.0, 0.1)\n",
        "yy = clf.intercept_[0]+ clf.coef_[0][1]*XX+ clf.coef_[0][2]*np.power(XX, 2)\n",
        "plt.plot(XX, yy, '-r' )\n",
        "plt.xlabel(\"Open\")\n",
        "plt.ylabel(\"Adj Close\")"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 28,
          "data": {
            "text/plain": [
              "Text(0,0.5,'Adj Close')"
            ]
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "image/png": [
              "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEKCAYAAAAfGVI8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3XmYVPWV//H3gYDSNP6EBo3R0CT+4gLRgGmN0cTEoIn7kokah8W9FUTRiRMXTNQYE+NEI0ZkU5RITRJn3JVoxLhER40NbiwuSYYmKiJIVASV7cwf95ZUV9fWTd2qrns/r+fpp6puVd361lNP16nvcs7X3B0REU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u5OLdFGqPipSIjM7EWhy93HVbotIOalHICKScOoRiIgknHoEIiIJp0AgIpJwCgQiIgmnQCAiknAKBCIiCadAICKScP8HBK5+u2bmRzEAAAAASUVORK5CYII=\n"
            ],
            "text/plain": [
              "<Figure size 432x288 with 1 Axes>"
            ]
          },
          "metadata": {}
        }
      ],
      "execution_count": 28,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Evaluation\n",
        "from sklearn.metrics import r2_score\n",
        "\n",
        "test_x_poly = poly.fit_transform(test_x)\n",
        "test_y_ = clf.predict(test_x_poly)\n",
        "\n",
        "print(\"Mean absolute error: %.2f\" % np.mean(np.absolute(test_y_ - test_y)))\n",
        "print(\"Residual sum of squares (MSE): %.2f\" % np.mean((test_y_ - test_y) ** 2))\n",
        "print(\"R2-score: %.2f\" % r2_score(test_y_ , test_y) )"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Mean absolute error: 0.13\n",
            "Residual sum of squares (MSE): 0.05\n",
            "R2-score: 1.00\n"
          ]
        }
      ],
      "execution_count": 29,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false
      }
    }
  ],
  "metadata": {
    "kernel_info": {
      "name": "python3"
    },
    "language_info": {
      "version": "3.5.5",
      "file_extension": ".py",
      "name": "python",
      "mimetype": "text/x-python",
      "pygments_lexer": "ipython3",
      "nbconvert_exporter": "python",
      "codemirror_mode": {
        "version": 3,
        "name": "ipython"
      }
    },
    "kernelspec": {
      "name": "python3",
      "language": "python",
      "display_name": "Python 3"
    },
    "nteract": {
      "version": "0.14.5"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 4
}